package com.sxbang.friday.service.impl;

import com.sxbang.friday.base.result.Results;
import com.sxbang.friday.dao.RoleDao;
import com.sxbang.friday.model.SysRole;
import com.sxbang.friday.model.SysUser;
import com.sxbang.friday.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    RoleDao roleDao;

    @Override
    public Results<SysRole> getAllRoles() {
        return Results.success(50,roleDao.getAllRoles());
    }

    @Override
    public Results<SysRole> selectRole(Integer offset, Integer limit) {
        return Results.success(roleDao.countAllUsers().intValue(),roleDao.selectRole(offset,limit));//返回两条数据，数据总条数，和分页后的数据
    }
    @Override
    public Results<SysRole> getUserByFuzzyUsername(String name, Integer offset, Integer limit) {
        return Results.success(roleDao.getUserByFuzzyUsername(name).intValue(),roleDao.getUserByFuzzyUsernameByPage(name,offset,limit));

    }
}
